Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSWriteASCII: Fix header & improve output #125

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

2xB
Copy link
Member

@2xB 2xB commented Dec 11, 2024

Previously, there were multiple issues with KSWriteASCII:

  • Headers could be in a different order than actual values (especially problematic since the order of the actual values seems to be somewhat random as found by executing the same simulation multiple times - this should be understood and fixed ideally, I couldn't understand it yet)
  • The header contained a mix of output for step and track
  • Likely run and event output was not correctly written to new lines

This is fixed by this commit:

Previous output:

gc_velocity_x	gc_velocity_y	gc_velocity_z	longitudinal_force	transverse_force	track_id	creator_name	terminator_name	total_steps	total_length	cont_energy_loss	disc_energy_loss	pixel_number	initial_time	initial_position_x	initial_position_y	initial_position_z	initial_radius	initial_magnetic_field_x	initial_magnetic_field_y	initial_magnetic_field_z	initial_electric_potential	initial_azimuthal_angle_to_x	initial_polar_angle_to_b	initial_kinetic_energy	final_time	final_position_x	final_position_y	final_position_z	final_magnetic_field_x	final_magnetic_field_y	final_magnetic_field_z	final_electric_potential	final_azimuthal_angle_to_x	final_polar_angle_to_b	final_kinetic_energy	maximal_magnetic_field_x	maximal_magnetic_field_y	maximal_magnetic_field_z	minimal_magnetic_field_x	minimal_magnetic_field_y	minimal_magnetic_field_z	maximal_electric_potential	minimal_electric_potential	step_id	step_length	cont_energy_loss	disc_energy_loss	time	position_x	position_y	position_z	momentum_x	momentum_y	momentum_z	magnetic_field_x	magnetic_field_y	magnetic_field_z	electric_field_x	electric_field_y	electric_field_z	electric_potential	polar_angle_to_b	kinetic_energy	longitudinal_kinetic_energy	
0	0.0118415	2.18279e-11	0	0	0.000925499	-0.000192499	-46.8343	-6.30205e-28	1.13437e-27	7.43511e-23	-4.60365e-05	-0.00148249	-0.492487	0	0	0	0	179.828	18600	18599.8	-192.971	-1430.19	4.46408	6.8586e-33	2.16194e-30	
1	0.0112013	0	0	1.50361e-10	0.000924978	-0.000155751	-46.8224	-1.91241e-26	-2.11848e-27	7.43511e-23	8.46511e-05	-0.00163606	-0.520617	0	0	0	0	179.818	18600	18599.8	-60.4305	-1229.88	3.86783	6.02887e-33	1.84457e-30	
2	0.0105529	3.63798e-12	0	2.92593e-10	0.000921915	-0.000120606	-46.8112	-3.53132e-26	-7.71004e-27	7.43511e-23	0.000208816	-0.00174806	-0.552605	0	0	0	0	179.813	18600	18599.8	56.0839	-1035.56	3.30716	5.20784e-33	1.54459e-30	
3	0.00991652	0	0	4.26591e-10	0.000916941	-8.73561e-05	-46.8007	-4.91636e-26	-1.53396e-26	7.43511e-23	0.0003301	-0.00186058	-0.588065	0	0	0	0	179.807	18600	18599.8	155.302	-855.047	2.80018	4.43308e-33	1.27373e-30	
4	0.00930669	-3.63798e-12	0	5.52509e-10	0.000910613	-5.61704e-05	-46.7907	-6.078e-26	-2.46789e-26	7.43511e-23	0.000447667	-0.00197187	-0.626599	0	0	0	0	179.801	18600	18599.8	237.579	-692.564	2.35473	3.7263e-33	1.0371e-30	
5	0.00873253	3.63798e-12	0	6.70683e-10	0.00090339	-2.71099e-05	-46.7814	-7.03446e-26	-3.54029e-26	7.43511e-23	0.00056076	-0.00208036	-0.667797	0	0	0	0	179.794	18600	18599.8	304.238	-549.652	1.97141	3.09703e-33	8.35214e-31	
6	0.00819895	-3.63798e-12	0	7.81567e-10	0.000895637	-1.56032e-07	-46.7727	-7.80778e-26	-4.7209e-26	7.43511e-23	0.000668712	-0.00218462	-0.711257	0	0	0	0	179.788	18600	18599.7	357.071	-426.068	1.64641	2.54648e-33	6.65851e-31	
7	0.00770771	3.63798e-12	0	8.85676e-10	0.000887629	2.4765e-05	-46.7645	-8.42105e-26	-5.9828e-26	7.43511e-23	0.000770963	-0.00228342	-0.756588	0	0	0	0	179.781	18600	18599.7	397.988	-320.53	1.37367	2.07082e-33	5.25455e-31	
8	0.0072584	0	0	9.83547e-10	0.000879572	4.77621e-05	-46.7568	-8.89656e-26	-7.30272e-26	7.43511e-23	0.000867063	-0.00237577	-0.803423	0	0	0	0	179.774	18600	18599.7	428.822	-231.251	1.14633	1.66352e-33	4.10037e-31	
9	0.00684924	0	0	1.07571e-09	0.000871608	6.89632e-05	-46.7495	-9.25486e-26	-8.66099e-26	7.4351e-23	0.000956669	-0.00246087	-0.851417	0	0	0	0	179.768	18600	18599.7	451.231	-156.277	0.957622	1.31701e-33	3.15697e-31	

New output:

# Run: 
# Event: 
# Track: track_id	creator_name	terminator_name	total_steps	total_length	cont_energy_loss	disc_energy_loss	pixel_number	initial_time	initial_position_x	initial_position_y	initial_position_z	initial_radius	initial_magnetic_field_x	initial_magnetic_field_y	initial_magnetic_field_z	initial_electric_potential	initial_azimuthal_angle_to_x	initial_polar_angle_to_b	initial_kinetic_energy	final_time	final_position_x	final_position_y	final_position_z	final_magnetic_field_x	final_magnetic_field_y	final_magnetic_field_z	final_electric_potential	final_azimuthal_angle_to_x	final_polar_angle_to_b	final_kinetic_energy	maximal_magnetic_field_x	maximal_magnetic_field_y	maximal_magnetic_field_z	minimal_magnetic_field_x	minimal_magnetic_field_y	minimal_magnetic_field_z	maximal_electric_potential	minimal_electric_potential	
# Step: step_id	step_length	cont_energy_loss	disc_energy_loss	time	position_x	position_y	position_z	momentum_x	momentum_y	momentum_z	magnetic_field_x	magnetic_field_y	magnetic_field_z	electric_field_x	electric_field_y	electric_field_z	electric_potential	polar_angle_to_b	kinetic_energy	longitudinal_kinetic_energy	gc_velocity_x	gc_velocity_y	gc_velocity_z	longitudinal_force	transverse_force	
step	0	0.0118415	2.18279e-11	0	0	0.000925499	-0.000192499	-46.8343	-6.30205e-28	1.13437e-27	7.43511e-23	-4.60365e-05	-0.00148249	-0.492487	0	0	0	0	179.828	18600	18599.8	-192.971	-1430.19	4.46408	6.8586e-33	2.16194e-30	
step	1	0.0112013	0	0	1.50361e-10	0.000924978	-0.000155751	-46.8224	-1.91241e-26	-2.11848e-27	7.43511e-23	8.46511e-05	-0.00163606	-0.520617	0	0	0	0	179.818	18600	18599.8	-60.4305	-1229.88	3.86783	6.02887e-33	1.84457e-30	
step	2	0.0105529	3.63798e-12	0	2.92593e-10	0.000921915	-0.000120606	-46.8112	-3.53132e-26	-7.71004e-27	7.43511e-23	0.000208816	-0.00174806	-0.552605	0	0	0	0	179.813	18600	18599.8	56.0839	-1035.56	3.30716	5.20784e-33	1.54459e-30	
step	3	0.00991652	0	0	4.26591e-10	0.000916941	-8.73561e-05	-46.8007	-4.91636e-26	-1.53396e-26	7.43511e-23	0.0003301	-0.00186058	-0.588065	0	0	0	0	179.807	18600	18599.8	155.302	-855.047	2.80018	4.43308e-33	1.27373e-30	
step	4	0.00930669	-3.63798e-12	0	5.52509e-10	0.000910613	-5.61704e-05	-46.7907	-6.078e-26	-2.46789e-26	7.43511e-23	0.000447667	-0.00197187	-0.626599	0	0	0	0	179.801	18600	18599.8	237.579	-692.564	2.35473	3.7263e-33	1.0371e-30	
step	5	0.00873253	3.63798e-12	0	6.70683e-10	0.00090339	-2.71099e-05	-46.7814	-7.03446e-26	-3.54029e-26	7.43511e-23	0.00056076	-0.00208036	-0.667797	0	0	0	0	179.794	18600	18599.8	304.238	-549.652	1.97141	3.09703e-33	8.35214e-31	
step	6	0.00819895	-3.63798e-12	0	7.81567e-10	0.000895637	-1.56032e-07	-46.7727	-7.80778e-26	-4.7209e-26	7.43511e-23	0.000668712	-0.00218462	-0.711257	0	0	0	0	179.788	18600	18599.7	357.071	-426.068	1.64641	2.54648e-33	6.65851e-31	
step	7	0.00770771	3.63798e-12	0	8.85676e-10	0.000887629	2.4765e-05	-46.7645	-8.42105e-26	-5.9828e-26	7.43511e-23	0.000770963	-0.00228342	-0.756588	0	0	0	0	179.781	18600	18599.7	397.988	-320.53	1.37367	2.07082e-33	5.25455e-31	
step	8	0.0072584	0	0	9.83547e-10	0.000879572	4.77621e-05	-46.7568	-8.89656e-26	-7.30272e-26	7.43511e-23	0.000867063	-0.00237577	-0.803423	0	0	0	0	179.774	18600	18599.7	428.822	-231.251	1.14633	1.66352e-33	4.10037e-31	
step	9	0.00684924	0	0	1.07571e-09	0.000871608	6.89632e-05	-46.7495	-9.25486e-26	-8.66099e-26	7.4351e-23	0.000956669	-0.00246087	-0.851417	0	0	0	0	179.768	18600	18599.7	451.231	-156.277	0.957622	1.31701e-33	3.15697e-31	

It has to be noted that I have absolutely no idea why the old MakeTitle function that I converted to a partially recursive Initialize function was called multiple times before (it was called again each time a new file was created for a new track) and that seemingly didn't cause issues.

2xB added 4 commits December 10, 2024 15:24
This code could if used cause unwanted behavior.
Before, the single header row contained a list of all outputs, mixing e.g. track and step outputs.
With this commit, there are multiple header rows, splitting the header up into step, track etc. output.
To use the header meaningfully, the further lines are also prepended by "track", "step" etc. indicating
their type.
Also, since outputs have been observed to change order at random (which still has to be understood and
if possible avoided), this commit uses fActive*Component to list the actually used components in their
correct order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant